Repository navigation
Believe X-Forwarded-For only from configured proxies - #13
Merged
Merged
Conversation
sv_proxies lists the reverse proxies to trust, off by default. The client address is the right-most header entry that is not one of them.
sv_proxies lists the reverse proxies to trust, off by default. The client address is the right-most header entry that is not one of them.
Two ways a client behind a trusted proxy could still choose its own address: - Only the first X-Forwarded-For line was read. A proxy that adds its own line instead of appending to the client's left the client's line first. - A hop that did not parse was skipped, so a proxy entry with a port made the walk continue into the client's own entries. All lines are now read in order, an entry with a port is read as its address, and any other unparseable hop ends the walk at the proxy's address. Also puts refusal()'s doc comment back on refusal() and runs cargo fmt over the branch. Co-Authored-By: Shiwang <shiwang@Shiwangs-MacBook-Air.local> Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Owner
|
Thanks for this, it does what #10 asked and the tests and docs are exactly right. While reviewing I found two cases where a client behind a trusted proxy could still pick its own address, so I pushed one commit (
Also in the commit: three tests for those cases, a paragraph in Locally on Windows: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10.
sv_proxies "127.0.0.1, 10.0.0.5"names the proxies to trust, empty by default. From a trusted peer the client address is the right-mostX-Forwarded-Forentry that is not itself a listed proxy, so a chain of two proxies works; from anywhere else the header is ignored. Three socket-level tests and both docs pages cover it.